# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=tolua
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=5.2.0
pkgrel=3
pkgdesc="A tool that greatly simplifies the integration of C/C++ code with Lua (mingw-w64)"
arch=('any')
url="http://www.tecgraf.puc-rio.br/~celes/tolua/"
license=('MIT')
depends=("${MINGW_PACKAGE_PREFIX}-lua")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc")
options=('staticlibs' 'strip' 'emptydirs')
source=(http://www.tecgraf.puc-rio.br/~celes/tolua/${_realname}-${pkgver}.tar.gz)
sha256sums=('f3d3836e9d2f11177fb3230ebb4c1ad8be74eb87fa95ce03a79d10df45ef89c3')

build() {
  cd ${srcdir}/${_realname}-${pkgver}
  sed -i "s|LUA=/usr/local|LUA=${MINGW_PREFIX}|g" config
  make -j1 \
    AR="ar rcu" \
    RANLIB="ranlib" \
    STRIP="strip" \
    CC="${MINGW_CHOST}-gcc"
}

package(){
  cd ${srcdir}/${_realname}-${pkgver}
  mkdir -p ${pkgdir}${MINGW_PREFIX}/{bin,lib,include}
  cp bin/*.exe ${pkgdir}${MINGW_PREFIX}/bin/
  cp lib/*.a ${pkgdir}${MINGW_PREFIX}/lib/
  cp include/*.h ${pkgdir}${MINGW_PREFIX}/include/
}
